package cn.xgj.sfzy.service.impl;

import cn.xgj.sfzy.entity.ChargeType;
import cn.xgj.sfzy.mapper.ChargeTypeMapper;
import cn.xgj.sfzy.service.ChargeTypeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author 张卫姣
 * @Date 2024年10月24日 11:45
 * @Version 1.0
 */
@Service
public class ChargeTypeServiceImpl implements ChargeTypeService {

    @Autowired
    private ChargeTypeMapper chargeTypeMapper;

    @Override
    public Integer add(ChargeType chargeType) {
        return chargeTypeMapper.insert(chargeType);
    }

    @Override
    public Integer remove(Integer chargeTypeId) {
        return chargeTypeMapper.delete(chargeTypeId);
    }

    @Override
    public Integer edit(ChargeType chargeType) {
        return chargeTypeMapper.update(chargeType);
    }

    @Override
    public List<ChargeType> findAll(ChargeType chargeType) {
        List<ChargeType> chargeTypes = chargeTypeMapper.selectAll(chargeType);
        return chargeTypes;
    }

    @Override
    public ChargeType findById(Integer chargeTypeId) {
        return chargeTypeMapper.selectById(chargeTypeId);
    }

    @Override
    public PageInfo<ChargeType> findByPage(Integer pageNum, Integer pageSize, ChargeType chargeType) {
        PageHelper.startPage(pageNum,pageSize);
        List<ChargeType> chargeTypes = chargeTypeMapper.selectAll(chargeType);
        PageInfo<ChargeType> pageInfo = new PageInfo<ChargeType>(chargeTypes);

        return pageInfo;

    }
}
